let root = {
	id: '1',
	label: 'first',
	children: [
		{
			id: '2',
			label: 'second',
		},
		{
			id: '3',
			label: 'third',
			children: [
				{
					id: '4',
					label: 'fourth',
				},
				{
					id: '5',
					label: 'fifth',
				},
			],
		},
	],
}
/**
 * 输入node和id返回匹配的节点
 * @param {*} root
 * @param {*} id
 */
function findNodeById(rootNode, id) {
	// 1. 判断节点id
	if (rootNode.id == id) {
		return rootNode
	}
	// 3. 遍历children
	if (Array.isArray(rootNode.children)) {
		for (let i = 0; i < rootNode.children.length; i++) {
		    let node = findNodeById(rootNode.children[i], id)
            if(node) return node
		}
	}
}

let node = findNodeById(root, '4')
console.log('node :', node.label)
